<template>
  <div>
    <div class="contbox6_10" v-if="type==0">
      <!-- 普通创建页 -->
      <p class="titlelist6_10">
        机构管理
        <span style="color: #999;">&nbsp;&nbsp;/&nbsp;&nbsp;</span>机构列表
        <span style="color: #999;">&nbsp;&nbsp;/&nbsp;&nbsp;</span>
        {{huinbian}}代理商
        <el-button style="float: right;margin-right: 30px;" type="primary" @click="shangyi()">返回</el-button>
      </p>
      <el-form ref="form" :model="form" label-width="120px">
        <el-form-item label="基本信息" style="width: 100%;float: left;font-weight: bold;">
          <span></span>
        </el-form-item>
        <el-form-item label="代理类型" style="width: 100%;float: left;">
          <span>代理商</span>
        </el-form-item>

        <el-form-item label="启用类型" style="width: 100%;float: left;">
          <el-select v-model="form.status" placeholder="请选择启用类型">
            <el-option label="启用" value="0"></el-option>
            <el-option label="停用" value="1"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="归属机构" style="width: 100%;float: left;">
          <el-select v-model="form.toOfficeUid" placeholder="请选择归属机构" @change="ps1()">
            <el-option
              v-for="(val,index) in guishu"
              :label="val.name"
              :value="val.uid"
              :key="index"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="指定权益" style="width: 100%;float: left;">
          <el-select v-model="form.channelUid" placeholder="请选择品牌" @change="ps()">
            <el-option
              v-for="(val, index) in paizi"
              :label="val.channelName"
              :value="val.uid"
              :key="index"
            ></el-option>
          </el-select>
          <el-select v-model="form.merUid" placeholder="请选择权益">
            <el-option
              v-for="(val, index) in huiyuanzhazi"
              :label="val.name"
              :value="val.uid"
              :key="index"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="机构名称" style="width: 100%;float: left;">
          <el-input v-model="form.officeName" style="width: 200px;margin-right: 40px;"></el-input>
        </el-form-item>
        <el-form-item label="负责人" style="width: 100%;float: left;">
          <el-input v-model="form.master" style="width: 200px;margin-right: 40px;"></el-input>
        </el-form-item>
        <el-form-item label="机构电话" style="width: 100%;float: left;">
          <el-input v-model="form.phone" style="width: 200px;margin-right: 40px;"></el-input>
        </el-form-item>
        <el-form-item label="电子邮箱" style="width: 100%;float: left;">
          <el-input v-model="form.email" style="width: 200px;margin-right: 40px;"></el-input>
        </el-form-item>
        <el-form-item label="联系地址" style="width: 100%;float: left;">
          <el-cascader
            size="large"
            :options="options"
            v-model="selectedOptions"
            @change="handleChange"
          ></el-cascader>
        </el-form-item>
        <el-form-item label style="width: 100%;float: left;">
          <el-input v-model="form.address" style="width: 200px;margin-right: 40px;"></el-input>
        </el-form-item>

        <div style="width: 100%;float: left;border-bottom: 1px solid #eee;margin-bottom: 30px;"></div>
        <div v-if="form.toOfficeUid==guishups || huinbian=='编辑'">
          <!-- <div
            style="width: 100%;float: left;font-size: 17px;color: #222;margin-top: 20px;margin-bottom: 40px;"
          >照片信息</div>
          <el-row :gutter="20">
            <el-col :span="5">
              <el-upload
                class="avatar-uploader"
                action="no"
                :show-file-list="false"
                :on-remove="handleRemove"
                :on-success="handleAvatarSuccess"
                :before-upload="handlePictureCardPreview"
                accept="image/*"
                :http-request="uploadOk"
              >
                <img v-if="dialogImageUrl" :src="dialogImageUrl" class="avatar" />
                <i v-else class="el-icon-plus avatar-uploader-icon"></i>
              </el-upload>
              <p class="cardNo">身份证国徽面照片</p>
            </el-col>
            <el-col :span="5">
              <el-upload
                class="avatar-uploader"
                action="no"
                :show-file-list="false"
                :on-remove="handleRemove"
                :on-success="handleAvatarSuccess"
                :before-upload="handlePictureCardPreview"
                accept="image/*"
                :http-request="uploadOk"
              >
                <img v-if="dialogImageUrl" :src="dialogImageUrl" class="avatar" />
                <i v-else class="el-icon-plus avatar-uploader-icon"></i>
              </el-upload>
              <p class="cardNo">身份证人像面照片</p>
            </el-col>
            <el-col :span="5">
              <el-upload
                class="avatar-uploader"
                action="no"
                :show-file-list="false"
                :on-remove="handleRemove"
                :on-success="handleAvatarSuccess"
                :before-upload="handlePictureCardPreview"
                accept="image/*"
                :http-request="uploadOk"
              >
                <img v-if="dialogImageUrl" :src="dialogImageUrl" class="avatar" />
                <i v-else class="el-icon-plus avatar-uploader-icon"></i>
              </el-upload>
              <p class="cardNo">银行卡照片</p>
            </el-col>
          </el-row>-->
          <div
            style="width: 100%;float: left;font-size: 16px;color: #999;margin-top:40px"
          >代理商提现设置 创建一级代理可新建或选择已有，创建二级及以下则默认直属一代上级费率</div>
          <div
            style="width: 100%;float: left;font-size: 17px;color: #222;margin-top: 20px;margin-bottom: 40px;"
          >设置提现规则</div>
          <el-form-item label="银行支付手续费" style="width: 100%;float: left;" id="bankTile">
            <el-input v-model="form.payCost" type="number" style="width: 200px;margin-right: 10px;"></el-input>
            <span>%</span>
          </el-form-item>
          <el-form-item label="银行代付手续费" style="width: 100%;float: left;" id="bankTile">
            <el-input
              v-model="form.singleDrawServiceCharge"
              type="number"
              style="width: 200px;margin-right: 10px;"
            ></el-input>
            <span>元/笔</span>
          </el-form-item>
          <el-form-item label="银行代付手续费" style="width: 100%;float: left;" id="bankTile">
            <el-input v-model="form.taxRate" type="number" style="width: 200px;margin-right: 10px;"></el-input>
            <span>%</span>
          </el-form-item>
          <!-- <el-form-item label="提现费率" style="width: 100%;float: left;">
            <el-input v-model="form.taxRate" type="number" style="width: 200px;margin-right: 10px;"></el-input>
            <span>%</span>
          </el-form-item>
          <el-form-item label="手续费" style="width: 100%;float: left;">
            <el-input
              v-model="form.singleDrawServiceCharge"
              type="number"
              style="width: 200px;margin-right: 10px;"
            ></el-input>
          <span>元/笔</span>-->
          <!-- </el-form-item> -->
          <el-form-item label="单笔最低" style="width: 100%;float: left;">
            <el-input
              v-model="form.singleDrawAmt"
              type="number"
              style="width: 200px;margin-right: 10px;"
            ></el-input>
            <span>元</span>
          </el-form-item>
          <el-form-item label="单日封顶" style="width: 100%;float: left;">
            <el-input
              v-model="form.dayDrawmaxAmt"
              type="number"
              style="width: 200px;margin-right: 10px;"
            ></el-input>
            <span>元</span>
          </el-form-item>
          <el-form-item label="提现次数" style="width: 100%;float: left;">
            <el-input
              v-model="form.dayDrawmaxCnt"
              type="number"
              style="width: 200px;margin-right: 10px;"
            ></el-input>
            <span>次</span>
          </el-form-item>
        </div>
        <el-form-item style="float: left;margin-left: 20px; margin-top: 10px;text-align: right;">
          <el-button type="primary" @click="putong()">完成</el-button>
        </el-form-item>
      </el-form>
    </div>

    <div class="contbox6_10" v-if="type==2">
      <!-- oem创建页 -->
      <p class="titlelist6_10">
        机构管理
        <span style="color: #999;">&nbsp;&nbsp;/&nbsp;&nbsp;</span>机构列表
        <span style="color: #999;" v-if="type==2">&nbsp;&nbsp;/&nbsp;&nbsp;</span>
        <span v-if="jurisdiction==2">{{huinbian}}OEM</span>
        <span v-else>{{huinbian}}小o单</span>
        <el-button style="float: right;margin-right: 30px;" type="primary" @click="shangyi()">返回</el-button>
      </p>
      <el-form ref="form1" :model="form1" label-width="160px">
        <el-form-item label="基本信息" style="width: 100%;float: left;font-weight: bold;">
          <span></span>
        </el-form-item>
        <el-form-item label="代理类型" style="width: 100%;float: left;">
          <span v-if="jurisdiction==2">OEM</span>
          <span v-else>小o单</span>
        </el-form-item>
        <!-- <el-form-item label="启用类型" style="float: left;margin-right: 40px;" v-if="jurisdiction==2">
          <el-select v-model="form1.status" placeholder="请选择状态">
            <el-option label="启用" value="0"></el-option>
            <el-option label="停用" value="1"></el-option>
          </el-select>
        </el-form-item> -->

        <el-form-item label="启用类型" style="float: left;margin-right: 40px;">
          <el-select v-model="form1.status" placeholder="请选择状态">
            <el-option label="启用" value="0"></el-option>
            <el-option label="停用" value="1"></el-option>
          </el-select>
        </el-form-item>

        <el-form-item label="机构名称" style="width: 100%;float: left;">
          <el-input v-model="form1.officeName" style="width: 200px;margin-right: 40px;"></el-input>
        </el-form-item>
        <el-form-item label="负责人" style="width: 100%;float: left;">
          <el-input v-model="form1.master" style="width: 200px;margin-right: 40px;"></el-input>
        </el-form-item>
        <el-form-item label="机构电话" style="width: 100%;float: left;">
          <el-input v-model="form1.phone" style="width: 200px;margin-right: 40px;"></el-input>
        </el-form-item>
        <el-form-item label="电子邮箱" style="width: 100%;float: left;">
          <el-input v-model="form1.email" style="width: 200px;margin-right: 40px;"></el-input>
        </el-form-item>
        <el-form-item label="联系地址" style="width: 100%;float: left;">
          <el-cascader
            size="large"
            :options="options"
            v-model="selectedOptions"
            @change="handleChange"
          ></el-cascader>
        </el-form-item>
        <el-form-item label style="width: 100%;float: left;">
          <el-input
            v-model="form1.address"
            placeholder="请输入具体联系地址"
            style="width: 200px;margin-right: 40px;"
          ></el-input>
        </el-form-item>

        <div style="width: 100%;float: left;border-bottom: 1px solid #eee;margin-bottom: 30px;"></div>

        <div
          style="width: 100%;float: left;font-size: 16px;color: #999;margin-bottom: 30px;"
        >结算信息（至少填写一种）</div>
        <div
          class="zouni6_12"
          style="width:50%;float: left;box-sizing: border-box; padding-left:15%;"
        >
          <el-form-item label="支付宝：" style="width: 100%;float: left;"></el-form-item>
          <el-form-item label="APPID" style="width: 100%;float: left;">
            <el-input v-model="form1.appId" style="width: 200px;margin-right: 40px;"></el-input>
          </el-form-item>
          <el-form-item label="支付宝账号" style="width: 100%;float: left;">
            <el-input v-model="form1.aliNo" style="width: 200px;margin-right: 40px;"></el-input>
          </el-form-item>
          <el-form-item label="联系人姓名" style="width: 100%;float: left;">
            <el-input v-model="form1.aliName" style="width: 200px;margin-right: 40px;"></el-input>
          </el-form-item>
          <el-form-item label="电子邮箱" style="width: 100%;float: left;">
            <el-input v-model="form1.aliEmail" style="width: 200px;margin-right: 40px;"></el-input>
          </el-form-item>
          <el-form-item label="机构电话" style="width: 100%;float: left;">
            <el-input v-model="form1.aliPhone" style="width: 200px;margin-right: 40px;"></el-input>
          </el-form-item>
        </div>

        <div
          class="zouni6_12"
          style="width:49%;box-sizing: border-box; padding-left:15%;float: left;border-left:1px solid #eee;"
        >
          <el-form-item label="银行卡（对公）：" style="width: 100%;float: left;"></el-form-item>
          <!-- <el-form-item label="账户类型" style="float: left;margin-right: 40px;">
            <el-select v-model="form1.accountType" placeholder="请选择账户类型">
              <el-option label="对公" value="1"></el-option>
              <el-option label="对私" value="2"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="结算账户名" style="width: 100%;float: left;">
            <el-input v-model="form1.accountName" style="width: 200px;margin-right: 40px;"></el-input>
          </el-form-item>
          <el-form-item label="结算账号" style="width: 100%;float: left;">
            <el-input v-model="form1.accountNo" style="width: 200px;margin-right: 40px;"></el-input>
          </el-form-item>
          <el-form-item label="开户银行" style="width: 100%;float: left;">
            <el-input v-model="form1.bankName" style="width: 200px;margin-right: 40px;"></el-input>
          </el-form-item>
          <el-form-item label="开户支行" style="width: 100%;float: left;">
            <el-input v-model="form1.openBank" style="width: 200px;margin-right: 40px;"></el-input>
          </el-form-item>
          <el-form-item label="开户身份证号" style="width: 100%;float: left;">
            <el-input v-model="form1.certNbr" style="width: 200px;margin-right: 40px;"></el-input>
          </el-form-item>
          <el-form-item label="银行预留手机号" style="width: 100%;float: left;">
            <el-input v-model="form1.reservedMobile" style="width: 200px;margin-right: 40px;"></el-input>
          </el-form-item>-->

          <el-form-item label="分账权限" style="float: left;margin-right: 40px;">
            <el-select v-model="form1.isFlag" placeholder="请选择状态">
              <el-option label="停用" value="1"></el-option>
              <el-option label="启用" value="0"></el-option>
          </el-select>
            <el-tooltip placement="top">
              <div slot="content">
                分账权限开关<br/>
                <br />开启：设置OEM分账入口信息，OEM开通账户后，旗下代理可以使用银行卡进行提现；</br/>
                <br/>关闭：关停OEM下各个代理用银行卡提现的权限。
              </div>
              <i class="el-icon-question" />
            </el-tooltip>
          </el-form-item>
          <el-form-item label="公司名称" style="width: 100%;float: left;">
            <el-input
              v-model="form1.custName"
              style="width: 200px;margin-right: 40px;"
              placeholder="请输入公司名称"
            ></el-input>
          </el-form-item>
          <el-form-item label="组织机构代码" style="width: 100%;float: left;">
            <el-input
              v-model="form1.organizCode"
              style="width: 200px;margin-right: 40px;"
              placeholder="请输入组织机构代码"
            ></el-input>
          </el-form-item>
          <!-- <el-form-item label="企业证件号码" style="width: 100%;float: left;">
            <el-input
              v-model="form1.organizationCode"
              style="width: 200px;margin-right: 40px;"
              placeholder="请输入企业证件号码"
            ></el-input>
          </el-form-item>-->
          <el-form-item label="开户银行" style="width: 100%;float: left;">
            <el-select v-model="form1.bankCode" placeholder="请选择开户银行">
              <el-option
                :label="item.bankName"
                :value="item.bankCode"
                v-for="(item,index) in bankList"
                :key="index"
              ></el-option>
            </el-select>
            <!-- <el-input v-model="form1.bankName" style="width: 200px;margin-right: 40px;"></el-input> -->
          </el-form-item>
          <el-form-item label="企业对公账号" style="width: 100%;float: left;">
            <el-input
              v-model="form1.accountNo"
              style="width: 200px;margin-right: 40px;"
              placeholder="请输入企业对公账号"
            ></el-input>
          </el-form-item>
          <el-form-item label="企业预留经办人手机号" style="width: 100%;float: left;">
            <el-input
              v-model="form1.principalPhone"
              style="width: 200px;margin-right: 40px;"
              placeholder="请输入企业预留经办人手机号"
            ></el-input>
          </el-form-item>
          <el-form-item label="法人姓名" style="width: 100%;float: left;">
            <el-input
              v-model="form1.legalPersonName"
              style="width: 200px;margin-right: 40px;"
              placeholder="请输入法人姓名"
            ></el-input>
          </el-form-item>
          <el-form-item label="法人证件号" style="width: 100%;float: left;">
            <el-input
              v-model="form1.legalPersonIdCard"
              style="width: 200px;margin-right: 40px;"
              placeholder="请输入法人证件号"
            ></el-input>
          </el-form-item>
          <!-- <el-form-item label="企业电子邮箱" style="width: 100%;float: left;">
            <el-input
              v-model="form1.corporateEmail"
              style="width: 200px;margin-right: 40px;"
              placeholder="请输入企业电子邮箱"
            ></el-input>
          </el-form-item>-->
        </div>

        <div style="width: 100%;float: left;border-bottom: 1px solid #eee;margin-bottom: 30px;"></div>
        <div style="width: 100%;float: left;font-size: 16px;color: #999;margin-bottom: 30px;">成本设置</div>
        <div v-if="jurisdiction==2">
          <el-form-item label="选择通道" style="width: 50%;float: left;">
            <el-select v-model="form1.channelId" placeholder="请选择">
              <el-option
                :label="val.channelName"
                :value="val.id"
                v-for="val in tongdao"
                :key="val.id"
              ></el-option>
            </el-select>
          </el-form-item>
        </div>
        <el-form-item label="银行支付手续费" style="width: 50%;float: left;">
          <el-input
            placeholder="请输入银行支付手续费"
            v-model="form1.payCost"
            style="width: 250px;margin-right: 10px;"
          ></el-input>
          <span>%</span>
        </el-form-item>

        <el-form-item label="银行代付手续费" style="width: 50%;float: left;">
          <el-input
            placeholder="请设置代付单笔扣款金额"
            v-model="form1.singleBehalfPayCost"
            style="width: 200px;margin-right: 10px;"
          ></el-input>
          <span>元/笔</span>
        </el-form-item>

        <el-form-item label="银行代付手续费" style="width: 50%;float: left;">
          <el-input
            placeholder="请设置代付扣款比例"
            v-model="form1.behalfPayCost"
            style="width: 250px;margin-right: 10px;"
          ></el-input>
          <span>%</span>
        </el-form-item>
        <div v-if="jurisdiction==2">
          <el-form-item label="手续费最高扣款比例" style="width: 50%;float: left;">
            <el-input
              placeholder="不得高于10%"
              v-model="form1.tallTaxPoint"
              style="width: 250px;margin-right: 10px;"
            ></el-input>
            <span>%</span>
          </el-form-item>

          <el-form-item label="手续费最高扣款金额" style="width: 50%;float: left;">
            <el-input
              placeholder="不得高于5元/笔"
              v-model="form1.tallBehalfPayCost"
              style="width: 250px;margin-right: 10px;"
            ></el-input>
            <span>元/笔</span>
          </el-form-item>
        </div>

        <!-- <div style="width: 100%;float: left;border-bottom: 1px solid #eee;margin-bottom: 30px;"></div>
        <div style="width: 100%;float: left;font-size: 16px;color: #999;margin-bottom: 30px;">备注信息</div>
        <div v-if="jurisdiction==2">
          <el-form-item label="选择通道" style="width: 100%;float: left;margin-right: 40px;">
            <el-select v-model="form1.channelId" placeholder="请选择">
              <el-option :label="val.channelName" :value="val.id" v-for="val in tongdao"></el-option>
            </el-select>
          </el-form-item>
        </div>-->

        <!-- <div style="width: 100%;float: left;border-bottom: 1px solid #eee;margin-bottom: 30px;"></div>
        <div style="width: 100%;float: left;font-size: 16px;color: #999;margin-bottom: 30px;">成本核算</div>
        <div v-if="jurisdiction==2">
         <el-form-item label="选择通道" style="width: 100%;float: left;margin-right: 40px;">
          <el-select v-model="form1.channelId" placeholder="请选择">
            <el-option :label="val.channelName" :value="val.id" v-for="val in tongdao"></el-option>
          </el-select>
        </el-form-item>
        </div>
        <el-form-item label="支付交易成本" style="width: 40%;float: left;">
          <el-input
            placeholder="用户付款需要支付的手续费"
            v-model="form1.payCost"
            style="width: 250px;margin-right: 10px;"
          ></el-input>
          <span>%</span>
        </el-form-item>

        <el-form-item label="代付交易成本" style="width: 40%;float: left;">
          <el-input
            placeholder="设置提现单笔成本"
            v-model="form1.behalfPayCost"
            style="width: 200px;margin-right: 10px;"
          ></el-input>
          <span>元/笔</span>
        </el-form-item>-->
        <div>
          <div style="width: 100%;float: left;border-bottom: 1px solid #eee;margin-bottom: 30px;"></div>
          <div style="width: 100%;float: left;font-size: 16px;color: #999;margin-bottom: 30px;">备注信息</div>
          <el-form-item label="是否提供发票" style="float: left;margin-right: 40px;">
          <el-select v-model="form1.bill" placeholder="请选择">
            <el-option label="是" value="0"></el-option>
            <el-option label="否" value="1"></el-option>
          </el-select>
        </el-form-item>
          <el-form-item label="结算税点" style="width: 30%;float: left;">
            <el-input v-model="form1.taxPoint" style="width: 200px;margin-right: 40px;"></el-input>
          </el-form-item>
          <el-form-item label="结算周期" style="float: left;margin-right: 40px;">
            <el-select v-model="form1.settlementPeriod" placeholder="请选择">
              <el-option label="周" value="7"></el-option>
              <el-option label="半月" value="15"></el-option>
              <el-option label="月" value="30"></el-option>
              <el-option label="季" value="120"></el-option>
            </el-select>
          </el-form-item>
        </div>
        <el-form-item style="width:100%;float: left; margin-top: 10px;text-align: left;">
          <el-button type="primary" @click="oemsnb()">完成</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script>
import { regionData, CodeToText, TextToCode } from "element-china-area-data";
// import Edit from "./edit"
export default {
  name: "route",
  data() {
    return {
      uid:null,
      listName:null,
      newType: "",
      huinbian: "",
      huixiantype: "",
      huiyuanzhazi: [],
      paizi: [],
      guishu: [],
      guishups: "",
      options: regionData,
      selectedOptions: [],
      type: 0,
      activeName: "first",
      tongdao: [],
      bankList: [], //开户银行
      
      form: {
        level: "",
        merName: "",
        oemUid: "",
        singleDrawServiceCharge: "", //银行代理手续费（元/笔）
        agtType: 1,
        officeUid: "",
        toOfficeUid: "",
        channelUid: "",
        merUid: "",
        status: "0",
        officeName: "",
        master: "",
        phone: "",
        email: "",
        areaId: "",
        city: "",
        county: "",
        address: "",
        taxRate: "",
        singleDrawAmt: "",
        dayDrawmaxAmt: "",
        dayDrawmaxCnt: "",
        payCost: "", //银行支付手续费

        // bankPayment: "", //银行支付手续费
        // bankPaid: "", //银行代付手续费率
        // bankBehalf : "",  //银行代付手续费（元/笔）
      },
        //完成时需要提交的代码
      form1: {
        channelId: "",
        // behalfPayCost: "",
        payCost: "", //银行支付手续费率%
        agtType: 0,
        officeUid: "",
        status: "0",
        officeName: "",
        master: "",
        phone: "",
        email: "",
        areaId: "",
        city: "",
        county: "",
        address: "",
        appId: "",
        aliNo: "",
        aliName: "",
        aliEmail: "",
        aliPhone: "",
        accountType: "",
        accountName: "",
        bankCode: "", //开户银行
        openBank: "",
        certNbr: "",
        reservedMobile: "",
        bill: "",
        taxPoint: "",
        settlementPeriod: "",

        isFlag: "1", //分账权限
        custName: "", //公司名称
        organizCode: "", //组织机构代码
        accountNo: "", //企业对公账号
        principalPhone: "", //企业预留经办人手机号
        legalPersonName: "", //法人姓名
        legalPersonIdCard: "", //法人证件号

        behalfPayCost: "", //银行代付手续费%
        singleBehalfPayCost: "", //银行代付手续费（元/笔）
        tallBehalfPayCost: "", //手续费最高扣款金额（元/笔）
        tallTaxPoint: "", //手续费最高比例（%）

        // permissions: "", //分账权限
        // companyName: "", //公司名称
        // organizationCode: "", //组织机构代码
        // openingBank: "", //开户银行
        // corporate: "", //企业对公账号
        // mobileNumber: "", //企业预留经办人手机号
        // personName: "", //法人姓名
        // personNo: "", //法人证件号
        // corporateEmail: "", //企业电子邮箱
        // bankcharges: "", //成本设置->银行支付手续费
        // commissionCharge: "", //银行代付手续费
        // procedureRates: "", //银行代付手续费率
        // invoice: "", //备注信息->是否提供发票
        // taxSettlement: "", //备注信息->结算税点
        // settlementInterval: "", //备注信息->结算周期
      },
      dialogImageUrl: "",
    //   urltype: this.GLOBAL.httpurl,
    };
  },
created(){
    let cc = this.$route.params.id
    let name = this.$route.params.name
    // alert(cc)
    //获取列表页面传递过来的id
    this.uid = cc
    this.name = name
    // alert(this.name)
},
  mounted: function () {
    window.scrollTo(0, 0);
    var _this = this;
    _this.type = sessionStorage.getItem("newType");
    _this.huinbian = sessionStorage.getItem("huinbian");
    _this.huixianid = sessionStorage.getItem("huixianid");
    _this.jurisdiction = localStorage.getItem("jurisdiction");
    _this.LoginId = sessionStorage.getItem("LoginId");

    // _this.newType = sessionStorage.getItem("newType");
    console.log(4545, _this.type);
    console.log("类型", _this.jurisdiction);

    _this.tonjid();
    _this.gui(); //归属
    _this.openBankList(); //开户银行

    _this.form = {
      level: "",
      merName: "",
      oemUid: "",
      agtType: 1,
      officeUid: "",
      toOfficeUid: "",
      channelUid: "",
      merUid: "",
      status: "0",
      officeName: "",
      master: "",
      phone: "",
      email: "",
      areaId: "",
      city: "",
      county: "",
      address: "",
      taxRate: "", //银行代付手续费率
      singleDrawAmt: "",
      dayDrawmaxAmt: "",
      dayDrawmaxCnt: "",
      singleDrawServiceCharge: "",
      payCost: "", //银行支付手续费率    this.form.bankPayment
      singleDrawServiceCharge: "", //银行代付手续费(元/笔)
      // taxRate : this.form.bankPaid, //银行代付手续费率
    };
    _this.form1 = {
      channelId: "",
      // behalfPayCost: "",
      payCost: "",
      agtType: 0,
      officeUid: "",
      status: "0",
      officeName: "",
      master: "",
      phone: "",
      email: "",
      areaId: "",
      city: "",
      county: "",
      address: "",
      appid: "",
      aliNo: "",
      aliName: "",
      aliEmail: "",
      aliPhone: "",
      accountType: "",
      accountName: "",
      accountNo: "",
      bankCode: "", //开户银行
      openBank: "",
      certNbr: "",
      reservedMobile: "",
      bill: "",
      taxPoint: "",
      settlementPeriod: "",

      isFlag: "1", //分账权限
      custName: "", //公司名称
      organizCode: "", //组织机构代码
      accountNo: "", //企业对公账号
      principalPhone: "", //企业预留经办人手机号
      legalPersonName: "", //法人姓名
      legalPersonIdCard: "", //法人证件号

      behalfPayCost: "", //银行代付手续费%
      singleBehalfPayCost: "", //银行代付手续费（元/笔）
      tallBehalfPayCost: "", //手续费最高扣款金额（元/笔）
      tallTaxPoint: "", //手续费最高比例（%）
    };
    if (
      sessionStorage.getItem("huixianid") &&
      sessionStorage.getItem("huixianid") != ""
    ) {
      console.log(111);
      _this.huiixan();
    } else {
      console.log(222);
      _this.pingpai();
      _this.huiixan1();
    }
  },
  components: {},

  methods: {
    ps1() {
      var _this = this;

      if (
        sessionStorage.getItem("huixianid") &&
        sessionStorage.getItem("huixianid") != ""
      ) {
        _this.guishups = _this.form.toOfficeUid;
      }
    },
    ps() {
      var _this = this;
      _this
        .axios({
          //axios请求
          method: "post",
          url:"/api/member/queryMember",
          data: {
            channelUid: _this.form.channelUid,
          },
        })
        .then(function (d) {
          if (d.data.code == "0000") {
            _this.huiyuanzhazi = d.data.data;
            /*  _this.form.toOfficeUid = d.data.oemuid;*/
          } else {
            layer.open({
              content: d.data.msg,
              skin: "msg",
              time:  2, //1秒后自动关闭
            });
          }
        })
        .catch(function (error) {
          //axios请求失败回调
          console.log(error);
        });
    },
    pingpai() {
      var _this = this;
      _this
        .axios({
          //axios请求
          method: "post",
          url: "/api/brand/queryChannelNameList",
          data: {
            oemUid: localStorage.getItem("officeUid"),
          },
        })
        .then(function (d) {
          if (d.data.code == "0000") {
            _this.paizi = d.data.data;
            /*  _this.form.toOfficeUid = d.data.oemuid;*/
          } else {
            layer.open({
              content: d.data.msg,
              skin: "msg",
              time:  2, //1秒后自动关闭
            });
          }
        })
        .catch(function (error) {
          //axios请求失败回调
          console.log(error);
        });
    },
    gui() {
      var _this = this;
      // alert(this.uid)
      _this
        .axios({
          //axios请求
          method: "post",
          url: "/api/office/queryOffice",
          data: {
            oemUid: this.uid,
            officeName: localStorage.getItem("username"),
          },
        })
        .then(function (d) {
          if (d.data.code == "0000") {
            _this.guishu = d.data.data;
            console.log(
              555,
              sessionStorage.getItem("huixianid"),
              d.data.oemuid
            );
            sessionStorage.getItem("huixianid") == "" &&
              (_this.form.toOfficeUid = d.data.oemuid);
            _this.guishups = d.data.oemuid;
          } else {
            layer.open({
              content: d.data.msg,
              skin: "msg",
              time:  2, //1秒后自动关闭
            });
          }
        })
        .catch(function (error) {
          //axios请求失败回调
          console.log(error);
        });
    },
    tonjid() {
      var _this = this;
      _this
        .axios({
          //axios请求
          method: "post",
          url: "/api/channel/queryChannel",
          data: {},
        })
        .then(function (d) {
          if (d.data.code == "0000") {
            _this.tongdao = d.data.data;
          } else {
            layer.open({
              content: d.data.msg,
              skin: "msg",
              time:  2, //1秒后自动关闭
            });
          }
        })
        .catch(function (error) {
          //axios请求失败回调
          console.log(error);
        });
    },
    handleChange(value) {
      /* console.log(this.selectedOptions)*/
      /*this.form.areaId=CodeToText[value[0]];
       this.form.city=CodeToText[value[1]];
       this.form.county=CodeToText[value[2]];

       this.form1.areaId=CodeToText[value[0]];
       this.form1.city=CodeToText[value[1]];
       this.form1.county=CodeToText[value[2]];*/
      this.form.areaId = value[0];
      this.form.city = value[1];
      this.form.county = value[2];

      this.form1.areaId = value[0];
      this.form1.city = value[1];
      this.form1.county = value[2];
    },
    shangyi() {
      var _this = this;
      _this.$router.push({ name: "jglist" });
      sessionStorage.setItem("huixianid", "");
      _this.$emit("type", 1);
    },
    handleClick(tab, event) {
      console.log(tab, event);
    },
    huiixan() {
      console.log(5555567);
      var _this = this;
      _this
        .axios({
          //axios请求
          method: "post",
          url: "/api/office/getUpdateOfficeInfo",
          data: {
            officeUid: sessionStorage.getItem("huixianid"),
          },
        })
        .then(function (d) {
          if (d.data.code == "0000") {
            if (_this.type == 2) {
              _this.form1 = d.data.data;
              _this.selectedOptions = [];
              /* _this.selectedOptions.push(TextToCode[_this.form1.areaId]);
                                    _this.selectedOptions.push(TextToCode[_this.form1.city]);
                                    _this.selectedOptions.push(TextToCode[_this.form1.county]);*/
              _this.selectedOptions.push(_this.form1.areaId);
              _this.selectedOptions.push(_this.form1.city);
              _this.selectedOptions.push(_this.form1.county);
            } else if (_this.type == 0) {
              _this.form = d.data.data;
              _this.paizi = d.data.data.channel;
              _this.selectedOptions = [];
              _this.ps();
              /*_this.selectedOptions.push(TextToCode[_this.form.areaId]);
                                    _this.selectedOptions.push(TextToCode[_this.form.city]);
                                    _this.selectedOptions.push(TextToCode[_this.form.county]);*/
              _this.selectedOptions.push(_this.form.areaId);
              _this.selectedOptions.push(_this.form.city);
              _this.selectedOptions.push(_this.form.county);
            }
          } else {
            layer.open({
              content: d.data.msg,
              skin: "msg",
              time:  2, //1秒后自动关闭
            });
          }
        })
        .catch(function (error) {
          //axios请求失败回调
          console.log(error);
        });
    },
    huiixan1() {
      console.log(1111111111);
      var _this = this;
      _this
        .axios({
          //axios请求
          method: "post",
          url:"/api/office/getUpdateOfficeInfo",
          data: {
            officeUid: localStorage.getItem("officeUid"),
          },
        })
        .then(function (d) {
          if (d.data.code == "0000") {
            // if(_this.type==0){
            // _this.form1 = d.data.data;
            _this.form1 = {
              channelId: d.data.data.channelId,
              behalfPayCost: d.data.data.behalfPayCost, //银行代付手续费率
              payCost: d.data.data.payCost,
              singleBehalfPayCost: d.data.data.singleBehalfPayCost, //银行代付手续费元/笔
              bill: d.data.data.bill,
              tallTaxPoint: d.data.data.tallTaxPoint, //手续费最高扣款比例
              taxPoint: d.data.data.taxPoint,
              tallBehalfPayCost: d.data.data.tallBehalfPayCost, //手续费最高扣款金额
              settlementPeriod: d.data.data.settlementPeriod,

            };
          
          } else {
            layer.open({
              content: d.data.msg,
              skin: "msg",
              time:  2, //1秒后自动关闭
            });
          }
        })
        .catch(function (error) {
          //axios请求失败回调
          console.log(error);
        });
    },
    oemsnb() {
      var _this = this;
      console.log(454545, this.form1);

      if (!_this.form1.officeName)
        return layer.open({ content: "请填写机构名称", skin: "msg", time:  2 });
      if (!_this.form1.master)
        return layer.open({ content: "请填写负责人", skin: "msg", time:  2 });
      if (
        _this.form1.phone == "" ||
        _this.form1.phone == undefined ||
        _this.form1.phone.length < 11 ||
        _this.form1.phone.length > 11
      ) {
        layer.open({
          content: "请填写正确的手机号！",
          skin: "msg",
          time:  2, //1秒后自动关闭
        });
        return false;
      }
      if (!_this.form1.email)
        return layer.open({ content: "请填写邮箱", skin: "msg", time:  2 });
      var regCn = /[·！#￥（——）：；“”‘、，|《。》？、【】[\] ]/im;
      if (regCn.test(_this.form1.phone)) {
        layer.open({
          content: "手机号码不能含有特殊字符",
          skin: "msg",
          time:  2, //1秒后自动关闭
        });
        return false;
      }

      if (/[a-zA-Z]/im.test(_this.form1.phone)) {
        layer.open({
          content: "手机号码不能含有字母",
          skin: "msg",
          time:  2, //1秒后自动关闭
        });
        return false;
      }
      if (!/^1[3|4|5|7|8|9][0-9]\d{4,8}$/.test(_this.form1.phone)) {
        layer.open({
          content: "手机号码填写有误",
          skin: "msg",
          time:  2, //1秒后自动关闭
        });
        return false;
      }
      if (_this.form1.channelId == "")
        return layer.open({ content: "请选择通道", skin: "msg", time:  2 });
      if (_this.form1.behalfPayCost == "")
        return layer.open({
          content: "请输入支付交易成本",
          skin: "msg",
          time:  2,
        });
      if (_this.form1.payCost == "")
        return layer.open({
          content: "请输入银行支付手续费", //已添加
          skin: "msg",
          time:  2,
        });
      if (_this.form1.bill == "")
        return layer.open({
          content: "请选择是否提供发票",
          skin: "msg",
          time:  2,
        });
      if (_this.form1.taxPoint == "")
        return layer.open({ content: "请输入结算税点", skin: "msg", time:  2 });
      if (_this.form1.settlementPeriod == "")
        return layer.open({ content: "请选择结算周期", skin: "msg", time:  2 });
      // channelId: d.data.data.channelId,
      // behalfPayCost: d.data.data.behalfPayCost,
      // payCost: d.data.data.payCost,
      // bill: d.data.data.bill,
      // taxPoint: d.data.data.taxPoint,
      // settlementPeriod: d.data.data.settlementPeriod

      _this
        .axios({
          //axios请求
          method: "post",
          url: "/api/office/save",
          data: _this.form1,
        })
        .then(function (d) {
          // console.log(JSON.stringify(d)+'111111111')
          if (d.data.code == "0000") {
            layer.open({
              content: d.data.msg,
              skin: "msg",
              time:  2, //1秒后自动关闭
            });
            _this.$emit("type", 1);
          } else {
            layer.open({
              content: d.data.msg,
              skin: "msg",
              time:  2, //1秒后自动关闭
            });
          }
        })
        .catch(function (error) {
          //axios请求失败回调
          console.log(error);
        });
    },

    // 新增代理商
    putong() {
      var _this = this;
      const num = /^[0-9]*$/; //验证数字

      if (
        _this.form.phone == "" ||
        _this.form.phone.length < 11 ||
        _this.form.phone.length > 11
      ) {
        layer.open({
          content: "请填写正确的手机号！",
          skin: "msg",
          time:  2, //1秒后自动关闭
        });
        return false;
      }
      var regCn = /[·！#￥（——）：；“”‘、，|《。》？、【】[\] ]/im;
      if (regCn.test(_this.form.phone)) {
        layer.open({
          content: "手机号码不能含有特殊字符",
          skin: "msg",
          time:  2, //1秒后自动关闭
        });
        return false;
      }

      if (/[a-zA-Z]/im.test(_this.form.phone)) {
        layer.open({
          content: "手机号码不能含有字母",
          skin: "msg",
          time:  2, //1秒后自动关闭
        });
        return false;
      }
      if (!/^1[3|4|5|7|8|9][0-9]\d{4,8}$/.test(_this.form.phone)) {
        layer.open({
          content: "手机号码填写有误",
          skin: "msg",
          time:  2, //1秒后自动关闭
        });
        return false;
      }

      for (var s = 0; s < _this.huiyuanzhazi.length; s++) {
        if (_this.huiyuanzhazi[s].uid == _this.form.merUid) {
          _this.form.level = _this.huiyuanzhazi[s].level;
          _this.form.merName = _this.huiyuanzhazi[s].name;
        }
      }
      _this.form.oemUid = localStorage.getItem("officeUid");
      _this
        .axios({
          //axios请求
          method: "post",
          url:  "/api/office/save",
          data: _this.form,
        })
        .then(function (d) {
          if (d.data.code == "0000") {
            layer.open({
              content: d.data.msg,
              skin: "msg",
              time:  2, //1秒后自动关闭
            });
            _this.$emit("type", 1);
          } else {
            layer.open({
              content: d.data.msg,
              skin: "msg",
              time:  2, //1秒后自动关闭
            });
          }
        })
        .catch(function (error) {
          //axios请求失败回调
          console.log(error);
        });
    },
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    showdou() {
      this.$refs.mychild.parentHandleclick();
    },

    /*上传图片*/
    handleRemove(file, fileList) {},
    handlePictureCardPreview(file) {},
    handleAvatarSuccess(res, file) {
      // this.imageUrl = URL.createObjectURL(file.raw);
    },
    uploadOk(val) {
      var formdata = new FormData();
      //可以通过append()方法来追加数据
      formdata.append("upfile", val.file);
      formdata.append("up_type", 1);
      this.up = formdata;
      this.$axios({
        method: "post",
        url: "v1/upload",
        data: this.up,
      }).then((res) => {
        if (res.status == 200) {
          this.dialogImageUrl = res.data.file_url;
        }
      });
    },

    // 开户银行下拉框
    openBankList() {
      var _this = this;
      _this
        .axios({
          //axios请求
          method: "post",
          url:  "/bank/queryBank",
          data: {},
        })
        .then(function (d) {
          console.log(JSON.stringify(d) + "00000");
          if (d.data.code == "0000") {
            _this.bankList = d.data.data;
            /*  _this.form.toOfficeUid = d.data.oemuid;*/
          } else {
            layer.open({
              content: d.data.msg,
              skin: "msg",
              time:  2, //1秒后自动关闭
            });
          }
        })
        .catch(function (error) {
          //axios请求失败回调
          console.log(error);
        });
    },
  },
};
</script>

<style scoped>
/* 单独样式 */
.contbox6_10 {
  width: 96%;
  margin-left: 2%;
  /*  height: 87.5vh; */
  overflow-x: auto;
  box-sizing: border-box;
  float: left;
}
.titlelist6_10 {
  width: 100%;
  float: left;
  font-size: 16px;
  color: #222;
  margin-top: 40px;
}
.sousuojg6_10 {
  float: left;
  font-size: 16px;
  color: #222;
  box-sizing: border-box;
  background-color: #f6f6f6;
  margin-top: 20px;
  border-radius: 5px;
}

.avatar-uploader .el-upload {
  border: 1px dashed #d9d9d9;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.avatar-uploader .el-upload:hover {
  border-color: #409eff;
}
.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 256px;
  height: 160px;
  line-height: 160px;
  text-align: center;
}
.avatar {
  width: 256px;
  height: 160px;
  display: block;
  border-radius: 4px;
}
.cardNo {
  text-align: center;
  font-size: 14px;
}
</style>
